/**
 * 
 */
package com.gosophia.conference.action.starting;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.conferenceManagement.starting.dto.ConferenceStartingDTO;
import com.gosophia.conferenceManagement.starting.ws.ConferenceTransientStoreWebService;
import com.gosophia.oa.action.JudgeCurrentUndertaker;
import com.gosophia.springsecurity.UserDetailsImpl;

/**
 * 功能：删除用户临时文件
 * 
 * @author tianchunyu
 * @since 2011-3-23 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("RemoveTransientStoreAction")
@Scope("prototype")
public class RemoveTransientStoreAction extends BaseSupportAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Long jobId;
	private boolean hasTransientStore;
	private final Logger logger = Logger.getLogger(this.getClass());

	private ConferenceStartingDTO conferenceStartingDTO;
	@Autowired
	private ConferenceTransientStoreWebService conferenceTransientStoreWebService;
	@Autowired
	private JudgeCurrentUndertaker judgeCurrentUndertaker;
	@Override
	public String _execute() throws Exception {

		// 得到当前用户
		UserDetailsImpl userDetails = (UserDetailsImpl) SecurityContextHolder
				.getContext().getAuthentication().getPrincipal();
		Long creatorId = userDetails.getUserAccountDTO().getUserInfoDTO()
				.getUserInfoId();
		if (jobId != null) {
			judgeCurrentUndertaker.judgeOperationAuthority(jobId);
		}
		conferenceTransientStoreWebService
				.deleteTransientInfoById(conferenceStartingDTO
						.getConferenceStartingDTOId());
		logger.debug("删除该用户的临时文件成功");
		if (jobId == null) {
			conferenceStartingDTO = null;
		}else{
			conferenceStartingDTO.setConferenceStartingDTOId(null);
		}
		hasTransientStore = false;
		return SUCCESS;
	}

	public Long getJobId() {
		return jobId;
	}

	public void setJobId(Long jobId) {
		this.jobId = jobId;
	}

	public boolean isHasTransientStore() {
		return hasTransientStore;
	}

	public void setHasTransientStore(boolean hasTransientStore) {
		this.hasTransientStore = hasTransientStore;
	}

	public ConferenceStartingDTO getConferenceStartingDTO() {
		return conferenceStartingDTO;
	}

	public void setConferenceStartingDTO(
			ConferenceStartingDTO conferenceStartingDTO) {
		this.conferenceStartingDTO = conferenceStartingDTO;
	}

}
